'## Copyright (c) 2011, Hacker Wez under the New BSD License, see glyphx-license.txt (http://glyphx.codeplex.com/)
Public Class glyph

    Dim last_footprint_offset As Integer = 0

    Public Property X() As Integer
        Get
            Return _X
        End Get
        Set(ByVal value As Integer)
            _X = value
        End Set
    End Property
    Private _X As Integer

    Public Property Y() As Integer
        Get
            Return _Y
        End Get
        Set(ByVal value As Integer)
            _Y = value
        End Set
    End Property
    Private _Y As Integer

    ''' <summary>
    ''' the index of the glyph in the glyphmap
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property Index() As Integer
        Get
            Return _Index
        End Get
        Set(ByVal value As Integer)
            _Index = value
        End Set
    End Property
    Private _Index As Integer

    ''' <summary>
    ''' chance of glyph changing
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property Volatility() As Integer
        Get
            Return _Volatility
        End Get
        Set(ByVal value As Integer)
            _Volatility = value
        End Set
    End Property
    Private _Volatility As Integer

    ''' <summary>
    ''' speed of decay 
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property Decay() As Integer
        Get
            Return _Decay
        End Get
        Set(ByVal value As Integer)
            _Decay = value
        End Set
    End Property
    Private _Decay As Integer

    ''' <summary>
    ''' speed of movement
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property Speed() As Integer
        Get
            Return _Speed
        End Get
        Set(ByVal value As Integer)
            _Speed = value
        End Set
    End Property
    Private _Speed As Integer

    ''' <summary>
    ''' clone a footprint glyph
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Function spawn_footprint() As footprint
        If (Me.Y - last_footprint_offset >= GLYPH_SPRITE_SIZE) Then
            last_footprint_offset = Me.Y
            Dim clone As New footprint
            With clone
                .X = Me.X
                .Y = Me.Y
                .Index = Me.Index
                .Decay = Me.Decay
                .Life = 100
            End With
            Return clone
        Else
            Return Nothing
        End If
    End Function

    Function ToDestPoint() As Drawing.Point
        Return New Drawing.Point(Me.X, Me.Y)
    End Function

    Function ToSourceRect() As Drawing.Rectangle
        Return New Drawing.Rectangle(Me.Index * GLYPH_SPRITE_SIZE, 0, GLYPH_SPRITE_SIZE, GLYPH_SPRITE_SIZE)
    End Function

    Function ToBlurSourceRect() As Drawing.Rectangle
        Return New Drawing.Rectangle(Me.Index * GLYPH_SPRITE_SIZE, GLYPH_SPRITE_SIZE, GLYPH_SPRITE_SIZE, GLYPH_SPRITE_SIZE)
    End Function

End Class
